package com.bw.culture.net

import androidx.lifecycle.MutableLiveData
import com.bw.common.vm.BaseViewModel
import com.bw.culture.entity.NewsEntity
import com.bw.http.utils.zgr.OkHttpClientManager

class CultureViewModel:BaseViewModel() {

    private val apiService = OkHttpClientManager.retrofitInstance.create(ApiService::class.java)

    val newsSuccess by lazy { MutableLiveData<List<NewsEntity>>() }

    fun getNews(){
        executeNetwork(
            {apiService.getNews()},
            newsSuccess::postValue
        )
    }

    val addNewsSuccess by lazy { MutableLiveData<NewsEntity>() }

    fun getAddNews(newsEntity: NewsEntity){
        executeNetwork(
            {apiService.getAddNew(newsEntity)},
            addNewsSuccess::postValue
        )
    }

}